home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / cf / sysconf.in < prev    next >
Encoding:
Text File  |  1994-09-05  |  13.9 KB  |  575 lines

  1. # --*-sh-*---------------------------------------------------------------
  2. #
  3. # sysconf.in
  4. #
  5. # Maurice LeBrun
  6. # IFS, University of Texas at Austin
  7. # 14-Jul-1994
  8. #
  9. # This script sets up config variables for a Unix-like system.
  10. # The stuff set here is very system-specific and not easy to automate.
  11. # Believe me, I wish it were!  Stuff like compiler names (ANSI C, Fortran)
  12. # and options are set here.
  13. #
  14. # This treatment is a little bit of overkill for PLplot, but some of it
  15. # comes from other projects, and you never know when it will turn out to
  16. # be useful..
  17. # -----------------------------------------------------------------------
  18.  
  19. # -----------------------------------------------------------------------
  20. # Compiler/linker variables
  21. #
  22. # The following shell variables are used.  They can be redefined as
  23. # appropriate for specific systems.
  24. #
  25. # CC        ANSI C compiler
  26. # OCC        Traditional C compiler
  27. # F77        Fortran 77 compiler
  28. # LDC        Linker for C programs
  29. # LDF        Linker for Fortran programs
  30. #
  31. # The following are only set if the appropriate capability is selected,
  32. # otherwise are null.  I need to specify one for each compiler used for
  33. # full generality (on some systems the syntax may differ slightly between
  34. # them).  Each is tagged with:
  35. #
  36. #    _C    for the C compiler
  37. #    _CXX    for the C++ compiler
  38. #    _F    for the Fortran 77 compiler
  39. #    _LC    for the C linker
  40. #    _LCXX    for the C++ linker
  41. #    _LF    for the Fortran 77 linker
  42. #
  43. # DEBUG_FLAG    Compile with debugging on
  44. # OPT_FLAG    Compile with optimization on
  45. # DBL_FLAG    Use double-precision
  46. # PROF_FLAG    Compile with profiling on
  47. # SYS_FLAGS    Misc system-specific compiler flags
  48. # -----------------------------------------------------------------------
  49.  
  50. # Defaults
  51.  
  52. M4="m4"
  53.  
  54. # Debugging
  55.  
  56. if test "$with_debug" = "yes"; then
  57.     with_opt="no"
  58.     DEBUG_FLAG_C="-g"
  59.     DEBUG_FLAG_CXX="-g"
  60.     DEBUG_FLAG_F="-g"
  61.     DEBUG_FLAG_LC="-g"
  62.     DEBUG_FLAG_LCXX="-g"
  63.     DEBUG_FLAG_LF="-g"
  64. fi
  65.  
  66. # Optimization
  67.  
  68. if test "$with_opt" = "yes"; then
  69.     OPT_FLAG_C="-O"
  70.     OPT_FLAG_CXX="-O"
  71.     OPT_FLAG_F="-O"
  72. fi
  73.  
  74. # Double precision
  75. # Note that although there is no truly standard way to invoke double
  76. # precision in Fortran from the command line, enough of them use "-r8"
  77. # that I've decided to make it the default.  
  78.  
  79. if test "$with_double" = "yes"; then
  80.     DBL_FLAG_C="-DDOUBLE"
  81.     DBL_FLAG_CXX="-DDOUBLE"
  82.     DBL_FLAG_M4="-DDOUBLE"
  83.     DBL_FLAG_F="-r8"
  84. fi
  85.  
  86. # Profiling
  87. # Not a good default for Fortran here, either.
  88.  
  89. if test "$with_profile" = "yes"; then
  90.     PROF_FLAG_C="-p"
  91.     PROF_FLAG_CXX="-p"
  92.     PROF_FLAG_LC="-p"
  93. fi
  94.  
  95. # -----------------------------------------------------------------------
  96. # Set compiler on a system-dependent basis.
  97. # Notes:
  98. #
  99. # - type "configure --with-gcc" to specify gcc from the command line
  100. # - type "configure --with-f2c" to specify f2c from the command line
  101. #
  102. # On some systems, gcc or f2c is the default.  On others, they are not
  103. # supported (e.g. UNICOS, Convex).  The f2c executable is expected to be
  104. # "fc" since some systems may have both programs.  If "fc" can't be found,
  105. # "f77" is tried instead.
  106. #
  107. # On systems where gcc or f2c are actually undesirable (e.g. on Crays --
  108. # gcc isn't ported and why would you want to use f2c?), I set with_gcc
  109. # and/or with_f2c to "no" to prevent their use.
  110. #
  111. # The actual setup for gcc or f2c is done AFTER the case statements.  Done
  112. # this way because they're pretty predictable across platforms, and this
  113. # way we can just override what is set below.  Systems that use gcc or f2c
  114. # by default should set shell variables as follows: with_gcc=yes (to get
  115. # gcc), or with_f2c=yes (to get f2c).  IMPORTANT: the command line
  116. # argument uses a "-" (dash) to separate words, while the shell variable
  117. # uses a "_" (underscore).
  118. # -----------------------------------------------------------------------
  119.  
  120. # Set up ANSI C compiler
  121.  
  122. if test -z "$CC"; then
  123.     CC="cc"
  124.     case "$system" in 
  125.     aix*|AIX*|rs*|RS*|ibm*|IBM* ) 
  126.         CC="xlc"
  127.     ;;
  128.     alpha*|ALPHA*|Alpha*|OSF* ) 
  129.         CC="cc -std"
  130.     ;;
  131.     convex*|ConvexOS* ) 
  132.         CC="cc -std"
  133.         with_gcc="no"
  134.     ;;
  135.     dg*|DG* ) 
  136.         CC="cc -ansi"
  137.     ;;
  138.     hp*|HP* ) 
  139.         CC="c89"
  140.     ;;
  141.     irix*|IRIX*|Irix*|sgi*|SGI* ) 
  142.         CC="cc -ansi"
  143.     ;;
  144.     linux*|LINUX*|Linux* ) 
  145.         with_gcc="yes"
  146.     ;;
  147.     next*|NeXT*|NEXT* ) 
  148.         with_gcc="yes"
  149.     ;;
  150.     SunOS-4* )
  151.         CC="acc"
  152.     ;;
  153.     sx*|Sx*|SX*|monte*|Monte*|MONTE* ) 
  154.         CC="cc -hansi"
  155.         with_gcc="no"
  156.     ;;
  157.     ultrix*|ULTRIX* ) 
  158.         with_gcc="yes"
  159.     ;;
  160.     CRAY* ) 
  161.         with_gcc="no"
  162.     ;;
  163.     esac
  164. fi
  165.  
  166. # Set up K&R C compiler
  167.  
  168. if test -z "$OCC"; then
  169.     OCC="cc"
  170.     case "$system" in 
  171.     SunOS-5.* )
  172.         OCC="cc -Xs"
  173.     ;;
  174.     esac
  175. fi
  176.  
  177. # Set up Fortran compiler
  178.  
  179. if test -z "$F77"; then
  180.     F77="f77"
  181.     case "$system" in 
  182.     aix*|AIX*|rs*|RS*|ibm*|IBM* ) 
  183.         F77="xlf"
  184.     ;;
  185.     dg*|DG* ) 
  186.         F77="ghf77"
  187.     ;;
  188.     hp*|HP* ) 
  189.         # The fort77 front-end uses a cc-like set of command line flags.
  190.  
  191.         F77="fort77"
  192.     ;;
  193.     linux*|LINUX*|Linux* ) 
  194.         with_f2c="yes"
  195.     ;;
  196.     next*|NeXT*|NEXT* ) 
  197.         with_f2c="yes"
  198.     ;;
  199.     sx*|Sx*|SX*|monte*|Monte*|MONTE* ) 
  200.         # The f77 front-end uses a cc-like set of command line flags,
  201.         # but I've had problems with it, so use f77sx here instead.
  202.  
  203.         F77="f77sx"
  204.         with_f2c="no"
  205.     ;;
  206.     CRAY* ) 
  207.         F77="cf77"
  208.         with_f2c="no"
  209.     ;;
  210.     esac
  211. fi
  212.  
  213. # -----------------------------------------------------------------------
  214. # gcc
  215. # -----------------------------------------------------------------------
  216.  
  217. if test "$with_gcc" = "yes"; then
  218.     CC="gcc"
  219.     OCC="gcc -traditional"
  220.  
  221.     if test "$with_warn" = "yes"; then
  222.     SYS_FLAGS_C="-Wall"
  223.     fi
  224.  
  225.     # There are very few platforms on which gcc supports shared libs
  226.     # For now, just disable.
  227.  
  228.     if test "$with_shlib" = "yes"; then
  229.     echo "Warning: no support for shared libs with gcc yet"
  230.     with_shlib="no"
  231.     fi
  232. fi
  233.  
  234. # -----------------------------------------------------------------------
  235. # f2c
  236. #
  237. # I give preference to the program "fc" for invoking f2c, since there may
  238. # be a vendor-supplied program called "f77".  Only if "fc" isn't found
  239. # do I fall back to "f77".
  240. #
  241. # The only option supported for f2c is --with-double.
  242. # -----------------------------------------------------------------------
  243.  
  244. if test "$with_f2c" = "yes"; then
  245.     AC_PROGRAM_CHECK(found_fc, fc, "yes", "no")
  246.     if test "$found_fc" = "yes" ; then
  247.     F77="fc"
  248.     else
  249.     AC_PROGRAM_CHECK(found_f77, f77, "yes", "no")
  250.     if test "$found_f77" = "yes" ; then
  251.         F77="f77"
  252.     else
  253.         echo "Warning: could not find \"fc\" or \"f77\""
  254.         with_f2c="no"
  255.     fi
  256.     fi
  257.  
  258.     DEBUG_FLAG_F=
  259.     OPT_FLAG_F=
  260.     PROF_FLAG_F=
  261.     SYS_FLAGS_F=
  262. fi
  263.  
  264. # -----------------------------------------------------------------------
  265. # Can finally set linker defaults.
  266. # -----------------------------------------------------------------------
  267.  
  268. if test -z "$LDC"; then
  269.     LDC="$CC"
  270. fi
  271. if test -z "$LDF"; then
  272.     LDF="$F77"
  273. fi
  274.  
  275. # -----------------------------------------------------------------------
  276. # Now get system-specific compiler flags.
  277. #
  278. # If your Fortran compiler supports auto-promotion to double precision, it
  279. # is best to set DBL_FLAG_F with the appropriate command option.  This is
  280. # only used for the PLplot demo programs -- the Fortran interface uses m4
  281. # to generate single and double precision versions.  So if your compiler
  282. # can't do command-line promotion to double precision, the only loss is
  283. # that you won't be able to run the Fortran demos in double precision.
  284. # -----------------------------------------------------------------------
  285.  
  286. case "$system" in 
  287.     aix*|AIX*|rs*|RS*|ibm*|IBM* ) 
  288.     if test "$with_double" = "yes" -a "$with_f2c" = "no"; then
  289.         DBL_FLAG_F="-qAUTODBL=DBLPAD"
  290.     fi
  291.     ;;
  292.     alpha*|ALPHA*|Alpha*|OSF* ) 
  293.  
  294.     # Note that the c optimize flag is set to -O1, as higher levels of
  295.     # optimization will mess up some diagonal dashed lines.  
  296.  
  297.     if test "$with_opt" = "yes"; then
  298.         OPT_FLAG_C="-O1"
  299.     fi
  300.     ;;
  301.     convex*|ConvexOS* ) 
  302.     if test "$with_opt" = "yes"; then
  303.         OPT_FLAG_C="-O3"
  304.         OPT_FLAG_F="-O3"
  305.     fi
  306.     ;;
  307.     dg*|DG* ) 
  308.     if test "$with_f2c" = "no"; then
  309.         SYS_FLAGS_F77="-novms -f77"
  310.         if test "$with_debug" = "yes"; then
  311.         DEBUG_FLAG_F="-g -ga -X18"
  312.         fi
  313.     fi
  314.     ;;
  315.     hp*|HP* ) 
  316.  
  317.     # Optimization levels than 1 may not be worth it.  Also, HP's
  318.     # optimizing preprocessor may not alway be reliable, so use at
  319.     # your own risk.
  320.  
  321.     if test "$with_opt2" = "yes" -a "$with_gcc" = "no"; then
  322.         OPT_FLAG_C="+O3 +OS"
  323.     fi
  324.  
  325.     # When with_warn is set, most or all warnings are enabled.
  326.     # Also use the following:
  327.     #  -z      turns off run-time dereferencing of NULL pointers (ld option)
  328.     #  +ESlit puts const data and strings in read-only memory (c89 option)
  329.  
  330.     if test "$with_warn" = "yes" -a "$with_gcc" = "no"; then
  331.         SYS_FLAGS_LC="-z"
  332.         SYS_FLAGS_C="+w1 +ESlit"
  333.         SYS_FLAGS_F="-w"
  334.     fi
  335.  
  336.     # Profiling
  337.     # Should not be used with shared libraries.
  338.  
  339.     if test "$with_profile" = "yes" -a "$with_gcc" = "no"; then
  340.         with_shlib="no"
  341.         PROF_FLAG_C="-G"
  342.         PROF_FLAG_F="-G"
  343.         PROF_FLAG_LC="-G"
  344.         PROF_FLAG_LF="-G"
  345.     fi
  346.  
  347.     # Shut off shared libraries if debugging.
  348.  
  349.     if test "$with_debug" = "yes"; then
  350.         with_shlib="no"
  351.     fi
  352.  
  353.     # Double precision -- use auto promotion from Fortran.  This works
  354.     # only under 9.x -- the 8.x Fortran compiler only has -R8, which
  355.     # promotes only constants and not variables.  You can use a macro
  356.     # for real or different sets of sources to get both single and
  357.     # double, though, and in fact I do this with the stub interface
  358.     # (for a bit more portability).  So if your Fortran compiler
  359.     # doesn't support promotion of real constants AND variables, the
  360.     # library will still build, but you won't be able to build the
  361.     # Fortran example programs in double precision.
  362.  
  363.     if test $with_double = "yes" -a "$with_f2c" = "no"; then
  364.         DBL_FLAG_F="+autodblpad"
  365.     fi
  366.     ;;
  367.     irix*|IRIX*|Irix*|sgi*|SGI* ) 
  368.     ;;
  369.     linux*|LINUX*|Linux* ) 
  370.     ;;
  371.     next*|NeXT*|NEXT* ) 
  372.     ;;
  373.     SunOS-* )
  374.     if test "$with_profile" = "yes"; then
  375.         PROF_FLAG_LC="-p -static"
  376.     fi
  377.     ;;
  378.     sx*|Sx*|SX*|monte*|Monte*|MONTE* ) 
  379.     LDF="f77 -w"
  380.  
  381.     # ALWAYS ALWAYS use the -b option otherwise some things get passed by
  382.     # value instead of by reference (demonstrating once again that truth is
  383.     # stranger than fiction).
  384.  
  385.     SYS_FLAGS_F="-pvctl nomsg -b"
  386.     if test "$with_warn" = "yes"; then
  387.         SYS_FLAGS_F="-e1 $SYS_FLAGS_F"
  388.     else
  389.         SYS_FLAGS_F="-e2 $SYS_FLAGS_F"
  390.     fi
  391.  
  392.     if test "$with_opt" = "yes"; then
  393.         OPT_FLAG_F="-O nomsg"
  394.     fi
  395.  
  396.     if test "$with_double" = "yes"; then
  397.         DBL_FLAG_F="-A dbl4"
  398.     fi
  399.     ;;
  400.     ultrix*|ULTRIX* ) 
  401.  
  402.     # Profiling (needs checking)
  403.  
  404.     if test "$with_profile" = "yes"; then
  405.         PROF_FLAG_LC="-p -static"
  406.     fi
  407.     ;;
  408.     CRAY* ) 
  409.     machine=`uname -m`
  410.     if test "$with_debug" = "yes" ; then
  411.         DEBUG_FLAG_F="-Wf\"-ez\""
  412.     fi
  413.  
  414.     OPT_FLAG_F= 
  415.  
  416.     case "$machine" in
  417.         CRAY-2 )
  418.         SYS_FLAGS_C="-h pagelm"
  419.         ;;
  420.     esac
  421.  
  422.     if test "$with_profile" = "yes" ; then
  423.         PROF_FLAG_C=
  424.         PROF_FLAG_F=
  425.         PROF_FLAG_LC=
  426.         PROF_FLAG_LF=
  427.         DEBUG_FLAG_C="-Gp"
  428.         DEBUG_FLAG_LC="-Gp"
  429.         DEBUG_FLAG_LF= 
  430.  
  431.         case "$machine" in
  432.         CRAY-2 )
  433.             LIBS=$LIBS -lprof -lsci -lu
  434.         ;;
  435.         * )
  436.             LIBS=$LIBS -lprof -lsci
  437.         ;;
  438.         esac
  439.     fi
  440.     ;;
  441.     * )     
  442.     ;;
  443. esac
  444.  
  445. # -----------------------------------------------------------------------
  446. # Set flags to generate shared libraries for systems that we know about.
  447. # Taken from BLT configure.in with some modifications.
  448. # -----------------------------------------------------------------------
  449.  
  450. echo "checking how to make shared libraries"
  451. SHLIB_CCFLAGS=""
  452. SHLIB_BUILD=""
  453. SHLIB_SUFFIX=""
  454. case "$system" in 
  455.     SunOS-4* ) 
  456.     SHLIB_CCFLAGS="-pic"
  457.     SHLIB_F77FLAGS="-pic"
  458.     SHLIB_BUILD="ld -assert pure-text -o"
  459.     SHLIB_SUFFIX='.so.$(MAJOR_VERSION).$(MINOR_VERSION)'
  460.     SALIB_SUFFIX='.sa.$(MAJOR_VERSION).$(MINOR_VERSION)'
  461.     ;;
  462.     HP-UX-* )
  463.     SHLIB_CCFLAGS="+z"
  464.     SHLIB_F77FLAGS="+z"
  465.     SHLIB_BUILD="ld -b -o"
  466.     SHLIB_SUFFIX=".sl"
  467.     ;;
  468.  
  469.     # The rest are probably broken.  Someone please fix them.
  470.     # Remove the 'with_shlib="no"' line, comments, and go wild.
  471.  
  472.     SunOS-5* )
  473.     with_shlib="no"
  474. #    SHLIB_CCFLAGS="-K pic"
  475. #    SHLIB_F77FLAGS="-K pic"
  476. #    SHLIB_BUILD="$CC '-G -ztext -h $(SHARED_LIBRARY)'"
  477. #    SHLIB_SUFFIX='.so.$(MAJOR_VERSION)'
  478.     ;;
  479.     OSF-1.* )
  480.     with_shlib="no"
  481. #    SHLIB_CCFLAGS="-fpic"
  482. #    SHLIB_F77FLAGS="-fpic"
  483. #    SHLIB_BUILD="$CC -shared"
  484. #    SHLIB_SUFFIX='.so.$(MAJOR_VERSION)'
  485.     ;;
  486.     IRIX-5.* )
  487.     with_shlib="no"
  488. #    SHLIB_CCFLAGS="-KPIC"
  489. #    SHLIB_F77FLAGS="-KPIC"
  490. #    SHLIB_BUILD="$CC -shared"
  491. #    SHLIB_SUFFIX='.so.$(MAJOR_VERSION)'
  492.     ;;
  493.     * )
  494.     echo "Don't know how to make shared libraries for $system"
  495.     with_shlib="no"
  496.     ;;
  497. esac
  498.  
  499. if test ! -z "SHLIB_CCFLAGS" ; then 
  500.     if test "$compiler" = "gcc" ; then
  501.     SHLIB_CCFLAGS="-fpic"
  502.     fi
  503. fi
  504.  
  505. AC_SUBST(SHLIB_BUILD)
  506. AC_SUBST(SHLIB_SUFFIX)
  507. AC_SUBST(SALIB_SUFFIX)
  508.  
  509. # -----------------------------------------------------------------------
  510. # Assemble finished compiler flags.
  511. # -----------------------------------------------------------------------
  512.  
  513. CC_FLAGS_NOOPT=\
  514. "-c $DBL_FLAG_C $DEBUG_FLAG_C $SYS_FLAGS_C $PROF_FLAG_C"
  515.  
  516. CXX_FLAGS_NOOPT=\
  517. "-c $DBL_FLAG_CXX $DEBUG_FLAG_CXX $SYS_FLAGS_CXX $PROF_FLAG_CXX"
  518.  
  519. F77_FLAGS_NOOPT=\
  520. "-c $DBL_FLAG_F $DEBUG_FLAG_F $SYS_FLAGS_F $PROF_FLAG_F"
  521.  
  522. CC_FLAGS=\
  523. "$CC_FLAGS_NOOPT $OPT_FLAG_C"
  524.  
  525. CXX_FLAGS=\
  526. "$CXX_FLAGS_NOOPT $OPT_FLAG_CXX"
  527.  
  528. F77_FLAGS=\
  529. "$F77_FLAGS_NOOPT $OPT_FLAG_F"
  530.  
  531. LDC_FLAGS=\
  532. "$PROF_FLAG_LC $SYS_FLAGS_LC $DEBUG_FLAG_LC"
  533.  
  534. LDCXX_FLAGS=\
  535. "$PROF_FLAG_LCXX $SYS_FLAGS_LCXX $DEBUG_FLAG_LCXX"
  536.  
  537. LDF_FLAGS=\
  538. "$PROF_FLAG_LF $SYS_FLAGS_LF $DEBUG_FLAG_LF"
  539.  
  540. M4_FLAGS="-S2000 -B8192 -DSYSTEM=$SYSTEM $DBL_FLAG_M4"
  541.  
  542. AC_SUBST(CC)
  543. AC_SUBST(OCC)
  544. AC_SUBST(F77)
  545. AC_SUBST(LDC)
  546. AC_SUBST(LDF)
  547.  
  548. AC_SUBST(CC_FLAGS)
  549. AC_SUBST(LDC_FLAGS)
  550. AC_SUBST(F77_FLAGS)
  551. AC_SUBST(LDF_FLAGS)
  552. AC_SUBST(SHLIB_CCFLAGS)
  553. AC_SUBST(SHLIB_F77FLAGS)
  554.  
  555. # -----------------------------------------------------------------------
  556. # Hacks to deal with optimizer failures.
  557. # -----------------------------------------------------------------------
  558.  
  559. CC_FLAGS_XWIN=$CC_FLAGS
  560. CC_FLAGS_SCCONT=$CC_FLAGS
  561.  
  562. case "$system" in 
  563.     aix*|AIX*|rs*|RS*|ibm*|IBM* ) 
  564.     CC_FLAGS_XWIN=$CC_FLAGS_NOOPT
  565.     ;;
  566.  
  567.     sx*|Sx*|SX*|monte*|Monte*|MONTE* ) 
  568.     CC_FLAGS_SCCONT=$CC_FLAGS_NOOPT
  569.     ;;
  570. esac
  571.  
  572. AC_SUBST(CC_FLAGS_XWIN)
  573. AC_SUBST(CC_FLAGS_SCCONT)
  574.  
  575.